package com.jsftoolkit.base.components;

import com.jsftoolkit.base.RequiresResources;
import com.jsftoolkit.base.ResourceConstants;
import com.jsftoolkit.gen.builder.ComponentBuilder;
import com.jsftoolkit.gen.info.PropertyInfo;
import com.jsftoolkit.utils.Utils;

public class IncludeResourceSpec extends ComponentBuilder {

	public static final PropertyInfo RESOURCE = new PropertyInfo(String.class,
			"resource", null, true);

	public static final PropertyInfo TYPE = new PropertyInfo(String.class,
			"type","Utils.getValue(getResource(),\"\").endsWith(\".css\") ? \"style\" : \"script\"");

	public static final PropertyInfo ENCODING = new PropertyInfo(String.class,
			"encoding", "\"UTF-8\"");

	public static final PropertyInfo FILTER = new PropertyInfo(boolean.class,
			"filter", "\"style\".equalsIgnoreCase(getType())");

	public static final PropertyInfo FILTER_BEAN = new PropertyInfo(
			String.class, "filterBean", ResourceConstants.class.getSimpleName()
					+ ".SKINNING_FILTER");
	{
		assert ResourceConstants.SKINNING_FILTER != null;
	}

	{
		abstractClass().named("IncludeResource").in(
				"com.jsftoolkit.base.components");
		ofType("com.jsftoolkit.IncludeResource").inFamily(
				"com.jsftoolkit.IncludeResource");

		requiring(ResourceConstants.class,Utils.class);

		andProperties(RESOURCE, TYPE, FILTER_BEAN, FILTER, ENCODING);

		implementing(RequiresResources.class);

		withConfig().registeringRenderer(""); 
	}

}
